{% extends '/pg/index.html' %}
{% block operation %}
<ul class="breadcrumb">
  <li><a href="/pg">Home</a></li>
  <li><a href="/pg/contenuti">Contenuti CMS</a></li>
  <li class="active">News</li>
</ul>
<h2 class="text-center">News</h2>

{% include "pg/btn_action.html" with context %}

{% include "pg/filterkey/fk_paginastatica.html" with context %}

{%endblock%}

{% block custom_js %}
<script type="text/javascript" src="/tpl/pg/js/plugins/tinymce/tiny_mce.js"></script>
<script type="text/javascript" src="/tpl/pg/js/plugins/tinymce/jquery.tinymce.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
    //function setupTinyMce(){

//tinyMCE.init({
    function setupTinyMce() {
$('textarea').tinymce({
    theme : "advanced",
    plugins :"safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
    // Theme options
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
    theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
     theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
     //theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_statusbar_location : "bottom",
    theme_advanced_resizing : true,
    convert_urls : false,

        // Replace values for the template plugin
        template_replace_values : {
                username : "Some User",
                staffid : "991234"
        }
    });
};
$(".Preview").hide()
$("#anteprima").hide()
$(".Edit_dao").hide()
$("#edit_dao").hide()
$("#print_dao").hide()

$('#tableContainer_ac').jtable({
    title: 'Tabella News',
    messages: window.italianMessages,
    defaultDateFormat:"dd-mm-yy",
    paging: true,
    pageSize: 20,
    sorting: true,
    selecting: true,
    create:false,

    actions: {
        listAction: '/pg/ac_News/List',
        deleteAction: '/pg/ac_News/Delete'
    },

    fields: {
        id: {key: true,create: false,edit: false,list: false},
        title: {title: 'Titolo',width: '10%',inputClass: 'validate[required]',},
        abstract: {title: 'Abstract', width: '12%',
            list: false,
        },
        body: {title: 'Corpo ', list: false, type: "textarea",inputClass: 'body',
        },
        publication_date: {
            title: 'Data Pubblicazione',
            width: '6%',
            create: false,
            edit:false,
        },
        clicks: {
            title: 'Clicks',
            width: '3%',
            create: false,
            edit: false,
        },
        active: {
            title: 'Attiva',
            width: '2%',
            type: 'checkbox',
            values: { '0': 'Inactive', '1': 'Active' },
            defaultValue: '1'},

    },
    selectionChanged: function () {
    //Get all selected rows

    var $selectedRows = $('#tableContainer_ac').jtable('selectedRows');
    $("#anteprima").hide();
    $('.Preview').empty();
    $("#print_dao").hide();
    $("#edit_dao").hide();

    if ($selectedRows.length > 0) {
        //Show selected rows
        $("#edit_dao").show()
        $("#anteprima").show()
        //$("#print_dao").show()

    }
},
}); //fine tabella


$('#tableContainer_ac').jtable('load');

$('#anteprima').attr('preview', '/pg/ac_News/Preview');
$('#new_dao').attr('nuovo_dao', '/pg/ac_News/Edit');
$('#edit_dao').attr('modifica_dao', '/pg/ac_News/Edit');

});
</script>
{% endblock %}
